package com.sky.controller.admin;

import com.sky.dto.DataReportDTO;
import com.sky.result.Result;
import com.sky.service.ReportService;
import com.sky.vo.OrderReportVO;
import com.sky.vo.SalesTop10ReportVO;
import com.sky.vo.TurnoverReportVO;
import com.sky.vo.UserReportVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.weaver.ast.Or;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 数据统计相关接口
 */
@Api(value = "/admin/report", tags = {"数据统计相关接口"})
@Slf4j
@RestController
@RequestMapping("/admin/report")
public class ReportController {
    @Autowired
    private ReportService reportService;

    /**
     * 营业款统计功能
     * @param dataReportDTO
     * @return
     */
    @ApiOperation(value = "营业额统计", notes = "营业额统计", httpMethod = "GET")
    @GetMapping("/turnoverStatistics")
    public Result<TurnoverReportVO> turnoverStatistics(DataReportDTO dataReportDTO) {
        return reportService.turnoverStatistics(dataReportDTO);
    }

    /**
     * 用户统计功能
     * @param dataReportDTO
     * @return
     */
    @ApiOperation(value = "用户统计功能", notes = "用户统计功能", httpMethod = "GET")
    @GetMapping("/userStatistics")
    public Result<UserReportVO> userStatistics(DataReportDTO dataReportDTO) {
        return reportService.userStatistics(dataReportDTO);
    }

    /**
     * 订单统计功能
     * @param dataReportDTO
     * @return
     */
    @ApiOperation(value = "订单统计功能", notes = "订单统计功能", httpMethod = "GET")
    @GetMapping("/ordersStatistics")
    public Result<OrderReportVO> ordersStatistics(DataReportDTO dataReportDTO) {
        return reportService.ordersStatistics(dataReportDTO);
    }

    /**
     * 销量top10统计功能
     * @param dataReportDTO
     * @return
     */
    @ApiOperation(value = "销量top10统计功能", notes = "销量top10统计功能", httpMethod = "GET")
    @GetMapping("/top10")
    public Result<SalesTop10ReportVO> top10(DataReportDTO dataReportDTO) {
        return reportService.top10(dataReportDTO);
    }
    /**
     * 报表导出功能
     */
    @GetMapping("/export")
    public void export(HttpServletResponse response) throws IOException {
        reportService.export(response);
    }
}
